@file:JvmName("DisplayUtil")
@file:JvmMultifileClass

package com.maple.common.utils

import android.content.Context
import android.util.TypedValue
import androidx.annotation.Dimension
import com.maple.common.helper.AppHelper


fun spToPx(spValue: Float): Float {
    return TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_SP,
        spValue,
        AppHelper.getApplication().resources.displayMetrics
    )
}

fun spToPx(spValue: Int): Int {
    return TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_SP,
        spValue.toFloat(),
        AppHelper.getApplication().resources.displayMetrics
    ).toInt()
}

fun spToPx(context: Context, @Dimension(unit = Dimension.SP) spValue: Float): Float {
    return TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_SP,
        spValue,
        context.resources.displayMetrics
    )
}

fun spToPx(context: Context, @Dimension(unit = Dimension.SP) spValue: Int): Float {
    return TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_SP,
        spValue.toFloat(),
        context.resources.displayMetrics
    )
}